package jdbc1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

/**
 * @Auther:lele
 * @Date:2025/3/11
 */
public class Testjdbc {
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        FileInputStream fileInputStream = new FileInputStream("src/jdbc1/jdbc.properties");
        properties.load(fileInputStream);
        String url = properties.getProperty("url");
        String user = properties.getProperty("user");
        String passWord = properties.getProperty("passWord");
        String driver = properties.getProperty("driver");
        System.out.println("url = " + url);
        System.out.println("user = " + user);
        System.out.println("password = " + passWord);
        System.out.println("driver = " + driver);
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, user, passWord);
        Statement statement = connection.createStatement();
        String sql = "select * from student";
        ResultSet resultSet = statement.executeQuery(sql);
        boolean next = resultSet.next();
        int stu_id = resultSet.getInt("stu_id");
        System.out.println("stu_id = " + stu_id);


    }
}
